﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BoletoElectronicoDesktop.PagoEmpresas
{
    public partial class FormSeleccionarBeneficiario : Form
    {

        public string idBeneficiario;
        public FormSeleccionarBeneficiario()
        {
            InitializeComponent();
        }

        private void FormSeleccionarBeneficiario_Load(object sender, EventArgs e)
        {
            //inicio con la ventana maximizada
            this.WindowState = FormWindowState.Maximized;
        }

        private void cbRubro_Click(object sender, EventArgs e)
        {
            //cargo las rubros en el ComboBox
            DataTable rubros = BeneficiarioDAO.ObtenerRubros();
            cbRubro.DataSource = rubros;
            cbRubro.DisplayMember = "DescripcionRubro";
            cbRubro.ValueMember = "IdRubro";
        }

        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            txtRazonSocial.Text = "";
            txtCalle.Text = "";
            txtNum.Text = "";
            txtPiso.Text = "";
            txtDepto.Text = "";
            cbRubro.DataSource = null;
            dataGridView1.DataSource = null;
        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            string rubro;
            if (cbRubro.Text == "")
                rubro = "";
            else
                rubro = cbRubro.SelectedValue.ToString();
            DataTable dt = BeneficiarioDAO.ObtenerBeneficiariosHabilitados(txtRazonSocial.Text, txtCalle.Text, txtNum.Text, txtPiso.Text, txtDepto.Text, "", rubro);
            dataGridView1.DataSource = dt;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //cargo el id del beneficiario al formulario 
            idBeneficiario = dataGridView1.CurrentRow.Cells["BeneficiarioID"].Value.ToString();

            //cierro el formulario
            Close();
        }
    }
}
